import numpy as np
import PIL.Image as Image


def extendImage(filepath):
    image = Image.open(filepath)
    inputs = np.array(image)
    h = inputs.shape[0]
    w = inputs.shape[1]
    
    inputsExtend = np.zeros(shape = (3*h,3*w))
    for i in range(h, 2*h):
        for j in range(w, 2*w):
            inputsExtend[i][j] = inputs[i-h][j-w]
    imageExtend = Image.fromarray(inputsExtend).convert("L")
    imageExtend.save("./graphicTransform/extendedRawImage.jpg")
    return inputsExtend

def translation(filename, u, v):
    filepath = "./graphicTransform/" + filename + ".jpg"
    image = Image.open(filepath)
    inputs = np.array(image)
    result = np.zeros_like(image)
    h = inputs.shape[0] // 3
    w = inputs.shape[1] // 3
    for i in range(h, 2*h):
        for j in range(w, 2*w):
            result[i+u][j+v] = inputs[i][j]
    translationImage = Image.fromarray(result).convert("L")
    translationImage.save("./graphicTransform/translation-" + str(u) + "-" + str(v) + ".jpg")

def euclidean(filename, u, v, theta):
    filepath = "./graphicTransform/" + filename + ".jpg"
    image = Image.open(filepath)
    inputs = np.array(image)
    result = np.zeros_like(image)

translation("extendedRawImage", 50, 50)